package com.hhkj.api.sale.common.session.holder;

import com.hhkj.api.sale.common.session.model.LoginSale;
import com.ruoyi.framework.login.api.ApiSessionHolder;
import lombok.experimental.UtilityClass;

/**
 * ApiSaleSessionHolder
 *
 * @author HHKJ-SERVER-ZJ
 * @since 2023/10/26 8:23
 */
@UtilityClass
public class ApiSaleSessionHolder {

    /**
     * 获取TTL中的LoginStudent
     *
     * @return 登录学员信息
     */
    public LoginSale getLoginSale() {

        Object sessionObj = ApiSessionHolder.getSessionObj();
        if (sessionObj instanceof LoginSale) {
            return (LoginSale) sessionObj;
        }
        return null;
    }


    /**
     * 获取学员id
     *
     * @return 学员id
     */
    public Long getSaleId() {
        LoginSale loginStudent = getLoginSale();
        if (loginStudent != null) {
            return loginStudent.getId();
        }
        return null;
    }


    /**
     * 清除
     */
    public void clear() {
        ApiSessionHolder.clear();
    }
}
